﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace WebServerX.Logging
{
    public static class Logger
    {
        #region Properties

        public static Stream OutStream
        {
            get { return Logger._outStream; }
            set { Logger._outStream = value; }
        }
        private static Stream _outStream = null;

        #endregion

        #region Public Static Methods

        public static void Log(string message)
        {
            Log(message, "\n");
        }

        public static void Log(string message, string newLine)
        {
            if (OutStream == null)
                return;

            string m = String.Format("{0}: {1}{2}", DateTime.Now, message, newLine);
            Byte[] b = ASCIIEncoding.ASCII.GetBytes(m);

            OutStream.Write(b, 0, b.Length);
        }

        #endregion
    }
}
